// pages/newgame/pages/pointranking/pointranking.js
// import req from '../../../../utils/req.js'
// var util = require('../../../../utils/util.js')
import req from '../../../utils/req'
var app = getApp()
Page({
  /**
   * 页面的初始数据
   */
  data: {
    selectresult: {
      // unionid: wx.getStorageSync('openid'),
      page: 1,
      size: 20
    },
    id: '',
    listData:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      id: wx.getStorageSync('openid')
    })
    this.getlist()
  },

  async getlist() {
    // 获取数据
    req.currencyList(this.data.selectresult).then(data => {
      console.log(data);
      let res = data
 
      if (this.data.selectresult.page == 1) {
        this.listData = []
      }
      this.setData({
        listData:  this.data.listData.concat(data.res.length>0?data.res:[]),
        hasmore:!(res.length<this.data.selectresult.size),
        today_currency:res.today_currency,
        total_currency:res.total_currency
      })
    })
  },
  onReachBottom() {
    if (this.listData.length < this.total) {
      let current = this.data.selectresult.page
      this.data.selectresult.page = current + 1
      this.getlist()
    }
  },
  onPullDownRefresh() {
    this.setData({
      selectresult: {
        unionid: wx.getStorageSync('openId'),
        page: 1,
        size: 20
      }
    })
    wx.showNavigationBarLoading()
    wx.showLoading({
      title: '加载中' //加载转圈显示
    })
    this.getlist().then(() => {
      wx.hideNavigationBarLoading() //完成停止加载
      wx.stopPullDownRefresh() //停止下拉刷新
    })
  },

 
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},
  onShareAppMessage(){}


})
